import request from "@/utils/request";
/**
 * 订单
 */
//状态
export function orderStatusJson() {
  return [
    { label: "全部", value: 0 },
    { label: "待付款", value: 1 },
    { label: "待配送", value: 2 },
    { label: "待收货", value: 3 },
    { label: "已收货", value: 4 },
    // { label: "已评价", value: 6 },
    { label: "退款中", value: 7 },
    { label: "已退款", value: 8 },
    { label: "已取消", value: 99 }
  ];
}
export function orderMallStatusJson() {
  return [
    { label: "全部", value: 0 },
    { label: "待付款", value: 1 },
    { label: "待配送", value: 2 },
    { label: "待收货", value: 3 },
    { label: "已收货", value: 4 },
    // { label: "已评价", value: 6 },
    { label: "退款中", value: 7 },
    { label: "已退款", value: 8 },
    { label: "已取消", value: 99 }
  ];
}

export function entrustBuyStatusJson() {
  return [
    { label: "全部", value: 0 },
    { label: "待付款", value: 1 },
    { label: "已付款", value: 2 },
    { label: "已收货", value: 4 },
    { label: "已取消", value: 99 }
  ];
}

export function entrustSellStatusJson() {
  return [
    { label: "全部", value: 0 },
    { label: "待配送", value: 2 },
    { label: "待收货", value: 3 },
    { label: "已收货", value: 4 },
    { label: "已完成", value: 100 }
  ];
}

// 小程序订单状态
export function wxOrderStatusJson() {
  return [
    { label: "全部", value: 0 },
    { label: "待付款", value: 1 },
    { label: "待配送", value: 2 },
    { label: "待收货", value: 3 },
    { label: "已收货", value: 4 },
    { label: "已评价", value: 6 },
    { label: "退款中", value: 7 },
    { label: "已退款", value: 8 },
    { label: "退货申请", value: 9 },
    { label: "退货中", value: 10 },
    { label: "已取消", value: 99 },
    { label: "已完成", value: 100 }
  ];
}

export function orderDeliverStatusJson() {
  return [
    { label: "待确认", value: 1 },
    { label: "已确认", value: 2 },
    { label: "运输中", value: 3 },
    { label: "已收货", value: 4 },
    { label: "已对账", value: 90 },
    { label: "已驳回", value: 98 },
    { label: "已取消", value: 99 }
  ];
}

/**
 * 类型
 * createChooseName创建订单时选择弹窗的标题名称
 * confirmOrderUser可以执行确认订单的用户类型
 * cancelOrderUser可以执行取消订单的用户类型
 */
export function orderTypeJson() {
  return [
    {
      label: "商城零售订单",
      value: 1,
      createChooseName: "",
      confirmOrderUser: [2],
      cancelOrderUser: [1]
    },
    {
      label: "提货单",
      value: 2,
      createChooseName: "采购订单",
      confirmOrderUser: [2],
      cancelOrderUser: [1]
    },
    {
      label: "发货单",
      value: 3,
      createChooseName: "提货单",
      confirmOrderUser: [1],
      cancelOrderUser: [2]
    },
    {
      label: "退货单",
      value: 4,
      createChooseName: "发货单",
      confirmOrderUser: [2],
      cancelOrderUser: [1]
    },
    {
      label: "对账单",
      value: 5,
      createChooseName: "发货单",
      confirmOrderUser: [1],
      cancelOrderUser: [2]
    },
    {
      label: "结算单",
      value: 6,
      createChooseName: "发货单",
      confirmOrderUser: [2],
      cancelOrderUser: [1]
    },
    {
      label: "集采采购单",
      value: 10,
      createChooseName: "",
      confirmOrderUser: [2],
      cancelOrderUser: [1]
    },
    {
      label: "挂牌采购单",
      value: 11,
      createChooseName: "",
      confirmOrderUser: [2],
      cancelOrderUser: [1]
    },
    {
      label: "竞价采购单",
      value: 12,
      createChooseName: "",
      confirmOrderUser: [2],
      cancelOrderUser: [1]
    },
    {
      label: "委托代购订单",
      value: 13,
    }
  ];
}
// 分页查询
export function orderPageByQo(params) {
  return request({
    url: "/dinner/order/pageByQo",
    method: "post",
    params,
    timeout: 60000
  });
}

// 创建订单（提货单、发货单、退货单）
export function orderCreate(data) {
  return request({
    url: "/dinner/order/create",
    method: "post",
    data
  });
}

// 取消订单
export function orderCancel(params, isMall) {
  return request({
    url: "/dinner/order/cancel",
    method: "post",
    params
  });
}

//确认订单
export function orderHandle(params) {
  return request({
    url: "/dinner/order/handle",
    method: "post",
    params
  });
}

// 申请退款
export function mallRefundApply(params) {
  return request({
    url: "/dinner/order/zcgj/refund/apply",
    method: "post",
    params
  });
}

// 确认退款/拒绝退款
export function mallRefundConfirm(id, isConfirm) {
  return request({
    url: isConfirm
      ? "/dinner/order/zcgj/refund/confirm"
      : "/dinner/order/zcgj/refund/refuse",
    method: "post",
    params: {
      id
    }
  });
}

//详情
export function orderGetById(params) {
  return request({
    url: "/dinner/order/getById",
    method: "post",
    params
  });
}

//获取可用的订单（创建提货单、发货单、退货单时，选择上一级订单选择使用）
export function orderListAble(type) {
  return request({
    url: "/dinner/order/listAble",
    method: "post",
    params: {
      type: type
    }
  });
}

//订单发货（发货单）
export function orderSend(params) {
  return request({
    url: "/dinner/order/send",
    method: "post",
    params
  });
}

//订单确认收货（发货单）
export function orderConfirm(params) {
  return request({
    url: "/dinner/order/confirm",
    method: "post",
    params
  });
}

//商城订单发货（发货单）
export function mallOrderSend(params) {
  return request({
    url: "/dinner/order/zcgj/send",
    method: "post",
    params
  });
}

//商城订单确认收货（发货单）
export function mallOrderConfirm(params) {
  return request({
    url: "/dinner/order/zcgj/confirm",
    method: "post",
    params
  });
}

//线下支付(结算单)
export function orderOfflinePay(params) {
  return request({
    url: "/dinner/order/offlinePay",
    method: "post",
    params
  });
}
/**
 * 询价单
 * @param {*} params
 */
// 分页查询
export function enquiryPageByQo(params) {
  return request({
    url: "/dinner/inquiry/pageByQo",
    method: "post",
    params
  });
}

// 批量删除
export function enquiryRemoveByIds(params) {
  return request({
    url: "/dinner/inquiry/removeByIds",
    method: "post",
    params
  });
}

// 批量已读
export function enquiryRead(params) {
  return request({
    url: "/dinner/inquiry/read",
    method: "post",
    params
  });
}

// 结算管理 结算单
export function ICBCb2bpay(params) {
  return request({
    url: "/dinner/ICBC/b2bpay",
    method: "post",
    params
  });
}
// 快递公司查询
export function queryLogCode(params) {
  return request({
    url: "/dinner/logistics/queryLogCode",
    method: "post",
    params
  });
}
// 获取物流信息
export function queryLogInfo(params) {
  return request({
    url: "/dinner/logistics/queryLogInfo",
    method: "post",
    params
  });
}
// 获取退款物流信息
export function queryTuiKuanLogInfo(params) {
  return request({
    url: "/dinner/logistics/refund/queryLogInfo",
    method: "post",
    params
  });
}

// 评价
export function CommentReleaseComment(params) {
  return request({
    url: "/dinner/comment/releaseComment",
    method: "post",
    params
  });
}

// 更新委托订单地址
export function updateOrderAddress(params) {
  return request({
    url: "/dinner/order/updateAddress",
    method: "post",
    params
  });
}

// 创建保证金订单
export function createOrderPay(params) {
  return request({
    url: "/dinner/order/create/pay",
    method: "post",
    params
  });
}

//保证金支付
export function orderDirectPay(params) {
  return request({
    url: "/dinner/order/directPay",
    method: "post",
    params
  });
}

//是否已经支付定金单 
export function orderCheckPay(params) {
  return request({
    url: "/dinner/order/checkPay",
    method: "post",
    params
  });
}

//小程序订单 同意退货
export function agreeReturnGood(params) {
  return request({
    url: "/front/xcxPay/refund/goods/accept",
    method: "post",
    params
  });
}

//小程序订单 不同意退货
export function disagreeReturnGood(params) {
  return request({
    url: "/front/xcxPay/refund/goods/disagree",
    method: "post",
    params
  });
}

//小程序订单 确认退款
export function requestConfirmRefund(params) {
  return request({
    url: "/front/xcxPay/refund/confirm",
    method: "post",
    params
  });
}

//小程序订单 改价
export function changeOrderPrice(params) {
  return request({
    url: "/dinner/order/changeOrderPrice",
    method: "post",
    params
  });
}

// 扫码订单状态
export function scanOrderStatusJson() {
  return [
    { label: "全部", value: 0 },
    { label: "待付款", value: 1 },
    { label: "已收货", value: 4 },
  ];
}

// 众茶优选订单状态
export function zcyxOrderStatusJson() {
  return [
    { label: "全部", value: 0 },
    { label: "待付款", value: 1 },
    { label: "待配送", value: 2 },
    { label: "待收货", value: 3 },
    { label: "已收货", value: 4 },
    { label: "已评价", value: 6 },
    { label: "退款中", value: 7 },
    { label: "已退款", value: 8 },
    { label: "退货申请", value: 9 },
    { label: "退货中", value: 10 },
    { label: "已取消", value: 99 },
    { label: "已完成", value: 100 }
  ];
}

// 众茶优选积分订单状态
// export function zcyxScoreOrderStatusJson() {
//   return [
//     { label: "全部", value: 0 },
//     { label: "待配送", value: 2 },
//     { label: "待收货", value: 3 },
//     { label: "已收货", value: 4 },
//   ];
// }

// 众茶优选积分订单分页查询
// export function scoreOrderPageByQo(params) {
//   return request({
//     url: "/dinner/order/score/pageByQo",
//     method: "post",
//     params,
//     timeout: 60000
//   });
// }

// 众茶优选积分订单详情
// export function scoreOrderGetById(params) {
//   return request({
//     url: "/dinner/order/score/getById",
//     method: "post",
//     params
//   });
// }

// 获取积分商品物流信息
// export function scoreQueryLogInfo(params) {
//   return request({
//     url: "/dinner/order/score/queryLogInfo",
//     method: "post",
//     params
//   });
// }

//众茶优选积分商城订单发货
// export function scoreOrderSend(params) {
//   return request({
//     url: "/dinner/order/score/send",
//     method: "post",
//     params
//   });
// }

//众茶优选积分商城订单确认收货
// export function scoreOrderConfirm(params) {
//   return request({
//     url: "/dinner/order/score/confirm",
//     method: "post",
//     params
//   });
// }

//商城自提订单确认发货
export function orderPick(params) {
  return request({
    url: "/dinner/order/zcgj/pick",
    method: "post",
    params
  });
}

//众茶优选积分商城自提订单确认发货
// export function scoreOrderPick(params) {
//   return request({
//     url: "/dinner/order/score/pick",
//     method: "post",
//     params
//   });
// }

//父子订单详情
export function orderGetFZById(params) {
  return request({
    url: "/dinner/order/getFZById",
    method: "post",
    params
  });
}

//线上下德邦快递单
export function getExpressOrder(params) {
  return request({
    url: "/dinner/logistics/labelOrder",
    method: "post",
    params
  });
}

//获取发票信息
export function getInvoiceByOrderId(params) {
  return request({
    url: "/dinner/order/invoice/getByOrderId",
    method: "post",
    params
  });
}

//经纪人商品下单接口
export function xcxOrderOfflinePay(params) {
  return request({
    url: "/front/zcyx/xcxPay/offlinePay",
    method: "post",
    params
  });
}